class CubicleAirConditionerData {
  final String name; // 方舱名称
  final String cubicleNo; // 方舱编号
  final String deviceNo; // 设备编号
  final String tag; // 标签
  final String address; // 地址
  final String dataType; // 数据类型
  final String dataName; // 名称
  final String unit; // 单位
  final double value; // a mocked value

  CubicleAirConditionerData({
    required this.name,
    required this.cubicleNo,
    required this.deviceNo,
    required this.tag,
    required this.address,
    required this.dataType,
    required this.dataName,
    required this.unit,
    required this.value,
  });

  factory CubicleAirConditionerData.fromJson(Map<String, dynamic> json) {
    return CubicleAirConditionerData(
      name: json['name'] ?? json['label'] ?? '',
      cubicleNo: json['cubicleNo'] ?? '',
      deviceNo: json['deviceNo'] ?? '',
      tag: json['tag'] ?? '',
      address: json['address'] ?? '',
      dataType: json['dataType'] ?? json['type'] ?? '',
      dataName: json['dataName'] ?? json['name'] ?? json['label'] ?? '',
      unit: json['unit'] ?? '',
      value: (json['value'] as num).toDouble(),
    );
  }
}

class SmartAirOutletData {
  final String tag; // 标签
  final String address; // 地址
  final String dataType; // 数据类型
  final String name; // 名称
  final String unit; // 单位
  final double value; // a mocked value

  SmartAirOutletData({
    required this.tag,
    required this.address,
    required this.dataType,
    required this.name,
    required this.unit,
    required this.value,
  });

  factory SmartAirOutletData.fromJson(Map<String, dynamic> json) {
    return SmartAirOutletData(
      tag: json['tag'] ?? '',
      address: json['address'] ?? '',
      dataType: json['dataType'] ?? json['type'] ?? '',
      name: json['name'] ?? json['label'] ?? '',
      unit: json['unit'] ?? '',
      value: (json['value'] as num).toDouble(),
    );
  }

  // Mock data for testing
  static List<SmartAirOutletData> getMockData() {
    return [
      SmartAirOutletData(
        tag: 'SAO_001',
        address: 'X40.0',
        dataType: 'BOOL',
        name: '送风机',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_002',
        address: 'X40.1',
        dataType: 'BOOL',
        name: '回风机',
        unit: '',
        value: 0.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_003',
        address: 'X40.2',
        dataType: 'BOOL',
        name: '新风机',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_004',
        address: 'X40.3',
        dataType: 'BOOL',
        name: '排风机',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_005',
        address: 'X40.4',
        dataType: 'BOOL',
        name: '冷却泵',
        unit: '',
        value: 0.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_006',
        address: 'X40.5',
        dataType: 'BOOL',
        name: '加热器',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_007',
        address: 'X40.6',
        dataType: 'BOOL',
        name: '湿度控制',
        unit: '',
        value: 0.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_008',
        address: 'X40.7',
        dataType: 'BOOL',
        name: '温度控制',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_009',
        address: 'X41.0',
        dataType: 'BOOL',
        name: '过滤器',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_010',
        address: 'X41.1',
        dataType: 'BOOL',
        name: '风阀控制',
        unit: '',
        value: 0.0,
      ),
    ];
  }

  static List<SmartAirOutletData> getMockDataXF02() {
    return [
      SmartAirOutletData(
        tag: 'SAO_011',
        address: 'X42.0',
        dataType: 'BOOL',
        name: '排风机',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_012',
        address: 'X42.1',
        dataType: 'BOOL',
        name: '送风机',
        unit: '',
        value: 0.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_013',
        address: 'X42.2',
        dataType: 'BOOL',
        name: '回风机',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_014',
        address: 'X42.3',
        dataType: 'BOOL',
        name: '新风机',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_015',
        address: 'X42.4',
        dataType: 'BOOL',
        name: '冷却泵',
        unit: '',
        value: 0.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_016',
        address: 'X42.5',
        dataType: 'BOOL',
        name: '加热器',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_017',
        address: 'X42.6',
        dataType: 'BOOL',
        name: '湿度控制',
        unit: '',
        value: 0.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_018',
        address: 'X42.7',
        dataType: 'BOOL',
        name: '温度控制',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_019',
        address: 'X43.0',
        dataType: 'BOOL',
        name: '过滤器',
        unit: '',
        value: 1.0,
      ),
      SmartAirOutletData(
        tag: 'SAO_020',
        address: 'X43.1',
        dataType: 'BOOL',
        name: '风阀控制',
        unit: '',
        value: 0.0,
      ),
    ];
  }
}